#ifndef THREADS_H
#define THREADS_H

#include <QFileIconProvider>
#include <QCryptographicHash>
#include <QTreeWidget>
#include <QUrlInfo>
#include <QThread>
#include <QDir>
#include <QObject>

#include <windows.h>

#include "settingsdialog.h"

class processThread : public QThread
{
    Q_OBJECT

public:
    processThread(QObject * parent = 0);

    settingsDialog * mySettings;
    QTreeWidget * mainWidget;

    float t_totalItemsCount;
    int   t_totalFilesCount;
    int   t_totalFoldersCount;

    void appendInfo( const QString&, QTreeWidgetItem * );
    void clear();
    void setRunMode( int );
    void setFilters( bool, bool );

    int deleted;
    int modified;
    int added;

signals:
    void makeStep( double );
    void calculateFinished();

protected:
    void run();

    void calculateDir( const QString& );
    void countItems();

    QFileInfoList getFileInfoList( QDir );
    void processDir( const QString&, QTreeWidgetItem * );
    void drawTreeItem( QTreeWidgetItem *, bool, const QFileInfo & );
    int customColumnNumber( const QString& );
    QString getConvertedSize( qint64 );
    QString getMd5Hash( const QString& );
    QString getFileAttr( const QString& );
    bool isItemFolder( QTreeWidgetItem * );
    QList<QTreeWidgetItem *> getTopLevelFolders();
    qlonglong getFolderItemSize( QTreeWidgetItem * );

    void refresh();
    int  deletedFolderItemsCount();
    void checkAdded( const QString&, QTreeWidgetItem * );
    QTreeWidgetItem* itemWith( const QString& );

    int getChildItemsCount( QTreeWidgetItem * );
    void redrawByViewMode();

private:
    double currStep;
    QStringList initialDirPathList;
    QList<QTreeWidgetItem *> rootItemList;
    int run_mode;

    bool processSubDirs;
    bool useNativeIcons;
};

#endif // THREADS_H
